package com.tjshop.android.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.tjshop.android.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.tjshop.android.model.Coupons;
import com.tjshop.android.model.tj.json.Goods;
import com.tjshop.android.util.ImageLoaderUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by gytaiSSD on 2014/12/29.
 */
public class GoodsListAdapter extends BaseAdapter {
	private LayoutInflater inflater;
	List<Goods> shopList;
	private Context mContext;

	public GoodsListAdapter(Context context, ArrayList<Goods> clist,
			LayoutInflater inflater) {
		this.inflater = inflater;
		shopList = clist;
		this.mContext = context;
	}

	@Override
	public int getCount() {
		return shopList.size();
	}

	@Override
	public Object getItem(int i) {
		return shopList.get(i);
	}

	@Override
	public long getItemId(int i) {
		return i;
	}

	@Override
	public View getView(int i, View view, ViewGroup viewGroup) {
		if (view == null) {
			view = inflater.inflate(
					R.layout.inc_activity_main_fragment_home_guest_item, null);
		}
		TextView item_title = (TextView) view.findViewById(R.id.item_title);
		TextView item_msg = (TextView) view.findViewById(R.id.item_msg);
		TextView item_ori_price = (TextView) view
				.findViewById(R.id.item_ori_pre_price);
		ImageView item_icon = (ImageView) view.findViewById(R.id.item_icon);
		item_title.setText(shopList.get(i).getGoods_name());
		item_msg.setText(shopList.get(i).getGoods_name());
		item_ori_price.setText(shopList.get(i).getShop_price());
		String iconPath = shopList.get(i).getGoods_thumb();
		ImageLoaderUtils.getInstance(mContext)
				.displayImage(iconPath, item_icon);
		return view;
	}
}
